<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch"
             label-width="68px">
      <el-form-item label="状态" prop="free30">
        <el-select v-model="queryParams.free30" placeholder="请选择状态" clearable size="small">
          <el-option
            v-for="dict in dict.type.management_class"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="管理类别" prop="managementClass">
        <el-select v-model="queryParams.managementClass" placeholder="请选择类别" clearable size="small">
          <el-option
            v-for="dict in dict.type.managementclass"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="管理单位" prop="managementUnit">
        <el-input
          v-model="queryParams.managementUnit"
          placeholder="请输入管理单位"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="台账编码" prop="free1">
        <el-input
          v-model="queryParams.free1"
          placeholder="请输入台账编码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="安装位置" prop="position">
        <el-input
          v-model="queryParams.position"
          placeholder="请输入安装位置"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="名称" prop="designation">
        <el-input
          v-model="queryParams.designation"
          placeholder="请输入名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="有效期">
      <el-date-picker
        v-model="daterangeNextVerification"
        size="small"
        style="width: 240px"
        value-format="yyyy-MM-dd"
        type="daterange"
        range-separator="-"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        unlink-panels="false"
      ></el-date-picker>
      </el-form-item>

      <!--      <el-form-item label="检定周期" prop="verificationCycle">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.verificationCycle"-->
      <!--          placeholder="请输入检定周期"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="末次检定日期" prop="lastVerification">-->
      <!--        <el-date-picker clearable size="small"-->
      <!--                        v-model="queryParams.lastVerification"-->
      <!--                        type="date"-->
      <!--                        value-format="yyyy-MM-dd"-->
      <!--                        placeholder="选择末次检定日期"-->
      <!--        >-->
      <!--        </el-date-picker>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="有效期" prop="expirationDate">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.expirationDate"-->
      <!--          placeholder="请输入有效期"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="次检定日期" prop="nextVerification">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.nextVerification"-->
      <!--          placeholder="请输入次检定日期"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="溯源单位" prop="traceableUnit">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.traceableUnit"-->
      <!--          placeholder="请输入溯源单位"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="溯源方式" prop="traceableMode">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.traceableMode"-->
      <!--          placeholder="请输入溯源方式"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="证书编号" prop="certificateNumber">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.certificateNumber"-->
      <!--          placeholder="请输入证书编号"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="证书结论" prop="certificateConclusion">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.certificateConclusion"-->
      <!--          placeholder="请输入证书结论"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="确认结论" prop="conclusion">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.conclusion"-->
      <!--          placeholder="请输入确认结论"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="状态" prop="confirmationState">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.confirmationState"-->
      <!--          placeholder="请输入状态"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="测量过程编号" prop="processNumber">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.processNumber"-->
      <!--          placeholder="请输入测量过程编号"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="校准计量" prop="calibrationRecord">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.calibrationRecord"-->
      <!--          placeholder="请输入校准计量"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="加入人员" prop="creator">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.creator"-->
      <!--          placeholder="请输入加入人员"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="加入时间" prop="creationtime">-->
      <!--        <el-date-picker clearable size="small"-->
      <!--                        v-model="queryParams.creationtime"-->
      <!--                        type="date"-->
      <!--                        value-format="yyyy-MM-dd"-->
      <!--                        placeholder="选择加入时间"-->
      <!--        >-->
      <!--        </el-date-picker>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="完善人员" prop="perfect">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.perfect"-->
      <!--          placeholder="请输入完善人员"-->
      <!--          clearable-->
      <!--          size="small"-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="完善时间" prop="perfecttime">-->
      <!--        <el-date-picker clearable size="small"-->
      <!--                        v-model="queryParams.perfecttime"-->
      <!--                        type="date"-->
      <!--                        value-format="yyyy-MM-dd"-->
      <!--                        placeholder="选择完善时间"-->
      <!--        >-->
      <!--        </el-date-picker>-->
      <!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['meter:ledger:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['meter:ledger:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['meter:ledger:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['meter:ledger:export']"
        >导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExportPlan"
          v-hasPermi="['meter:ledger:exportplan']"
        >导出计划
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['meter:ledger:import']"
        >导入
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-tag type="success">正常:{{queryCount.free20}}</el-tag>
      </el-col>
      <el-col :span="1.5">
        <el-tag type="warning">警告:{{queryCount.free21}}</el-tag>
      </el-col>
      <el-col :span="1.5">
        <el-tag type="danger">超期:{{queryCount.free22}}</el-tag>
      </el-col>
      <el-col :span="1.5">
        <el-tag type="A">A:{{queryCount.free23}}</el-tag>
      </el-col>
      <el-col :span="1.5">
        <el-tag type="B">B:{{queryCount.free24}}</el-tag>
      </el-col>
      <el-col :span="1.5">
        <el-tag type="C">C:{{queryCount.free25}}</el-tag>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="ledgerList" height="720"
              @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="状态" align="center" prop="free30">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.management_class" :value="scope.row.free30"/>
        </template>
      </el-table-column>
      <el-table-column label="计量台账编码" align="center" prop="free1"/>
      <el-table-column label="管理类别（A、B、C类）" align="center" prop="managementClass"/>
      <el-table-column label="管理单位" align="center" prop="managementUnit"/>
      <el-table-column label="名称（命名要最简体现供出方、需求方、介质、用途）" align="center" prop="designation"
                       width="350"
      />
      <el-table-column label="设备类型" align="center" prop="deviceType" width="200"/>
      <el-table-column label="安装位置" align="center" prop="position" width="200"/>
      <el-table-column label="测量介质/参数" align="center" prop="storageMedium"/>
      <el-table-column label="生产厂家" align="center" prop="brand" width="200"/>
      <el-table-column label="规格型号" align="center" prop="modelNumber"/>
      <el-table-column label="出厂编号" align="center" prop="process"/>
      <el-table-column label="测量范围" align="center" prop="measurementRange"/>
      <el-table-column label="误差" align="center" prop="errorMargin"/>
      <el-table-column label="属性" align="center" prop="stats" width="200"/>
      <el-table-column label="确定间隔" align="center" prop="verificationCycle" width="100"/>

      <el-table-column label="检定日期" align="center" prop="lastVerification" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastVerification, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="有效日期" align="center" prop="nextVerification"/>
      <el-table-column label="溯源方式（检定、校准）" align="center" prop="traceableMode"/>
      <el-table-column label="溯源单位" align="center" prop="traceableUnit"/>
      <el-table-column label="证书编号" align="center" prop="certificateNumber"/>
      <!--      <el-table-column label="证书图片" align="center" prop="area"/>-->
      <el-table-column label="确认结论" align="center" prop="conclusion"/>
      <el-table-column label="确认时间" align="center" prop="effect"/>
      <el-table-column label="确认人" align="center" prop="powersupplymode"/>
      <el-table-column label="状态（在用、送检、限用、停用、准用）" align="center" prop="confirmationState"/>
      <!--      <el-table-column label="说明书" align="center" prop="specification"/>-->
      <el-table-column label="执行标准" align="center" prop="instrumentlv"/>
<!--      <el-table-column label="加入人员" align="center" prop="creator"/>-->
<!--      <el-table-column label="加入时间" align="center" prop="creationtime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.creationtime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="完善人员" align="center" prop="perfect"/>
      <el-table-column label="完善时间" align="center" prop="perfecttime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.perfecttime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="删除人员" align="center" prop="deleteor"/>-->
<!--      <el-table-column label="删除时间" align="center" prop="deletetime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.deletetime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->


      <!--<el-table-column label="确认时间" align="center" prop="effect"/>-->
      <!--<el-table-column label="确认人" align="center" prop="brand"/>-->
      <!--<el-table-column label="管径/供电方式" align="center" prop="powersupplymode"/>-->
      <!--<el-table-column label="校准计量" align="center" prop="calibrationRecord"/>-->

      <!--<el-table-column label="数据采集" align="center" prop="dataAcquisition"/>-->
      <!--<el-table-column label="采集方式" align="center" prop="acquisitionmode"/>-->
      <!--&lt;!&ndash;      <el-table-column label="检定周期" align="center" prop="verificationCycle">&ndash;&gt;-->
      <!--&lt;!&ndash;      </el-table-column>&ndash;&gt;-->
      <!--<el-table-column label="次检定日期" align="center" prop="nextVerification"/>-->
      <!--<el-table-column label="证书结论" align="center" prop="certificateConclusion"/>-->
      <!--<el-table-column label="测量过程编号" align="center" prop="processNumber"/>-->
      <!--<el-table-column label="备注" align="center" prop="remark"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free1"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free2"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free3"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free4"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free5"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free6"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free7"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free8"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free9"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free11"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free12"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free13"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free14"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free15"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free16"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free17"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free18"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free19"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free20"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free21"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free22"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free23"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free24"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free25"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free26"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free27"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free28"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free29"/>-->
      <!--      <el-table-column label="预留字段" align="center" prop="free30"/>-->
      <el-table-column label="图片" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.area != '' && scope.row.area != null"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handlePicture(scope.row)"
            v-hasPermi="['meter:ledger:edit']"
          >图片
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['meter:ledger:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['meter:ledger:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加或修改计量台账对话框 -->
    <el-dialog :title="title" :visible.sync="pictureOpen" width="1500px" append-to-body>
      <el-form ref="form" :inline="true" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="证书图片">
          <imageUpload v-model="form.area"/>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!-- 添加或修改计量台账对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1500px" append-to-body>
      <el-form ref="form" :inline="true" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="计量台账编码" prop="free1">
          <el-input v-model="form.free1" placeholder="请输入计量台账编码"/>
        </el-form-item>
        <el-form-item label="管理类别" prop="managementClass">
          <el-input v-model="form.managementClass" placeholder="请输入管理类别"/>
        </el-form-item>
        <el-form-item label="管理单位" prop="managementUnit">
          <el-input v-model="form.managementUnit" placeholder="请输入管理单位"/>
        </el-form-item>
        <el-form-item label="名称" prop="designation">
          <el-input v-model="form.designation" placeholder="请输入名称"/>
        </el-form-item>
        <el-form-item label="设备类型" prop="deviceType">
          <el-input v-model="form.deviceType" placeholder="请输入设备类型"/>
        </el-form-item>
        <el-form-item label="安装位置" prop="position">
          <el-input v-model="form.position" placeholder="请输入安装位置"/>
        </el-form-item>
        <!--        <el-form-item label="测量介质/参数" prop="storageMedium">-->
        <!--          <el-input v-model="form.storageMedium" placeholder="请输入介质"/>-->
        <!--        </el-form-item>-->
        <el-form-item label="测量介质" prop="storageMedium">
          <el-input v-model="form.storageMedium" placeholder="请输入测量介质"/>
        </el-form-item>
        <el-form-item label="生产厂家" prop="brand">
          <el-input v-model="form.brand" placeholder="请输入生产厂家"/>
        </el-form-item>
        <el-form-item label="规格型号" prop="modelNumber">
          <el-input v-model="form.modelNumber" placeholder="请输入规格型号"/>
        </el-form-item>
        <el-form-item label="出厂编号" prop="process">
          <el-input v-model="form.process" placeholder="请输入出厂编号"/>
        </el-form-item>
        <el-form-item label="测量范围" prop="measurementRange">
          <el-input v-model="form.measurementRange" placeholder="请输入测量范围"/>
        </el-form-item>
        <el-form-item label="误差" prop="errorMargin">
          <el-input v-model="form.errorMargin" placeholder="请输入误差"/>
        </el-form-item>
        <el-form-item label="属性" prop="stats">
          <el-input v-model="form.stats" placeholder="请输入属性"/>
        </el-form-item>
        <el-form-item label="检定周期" prop="verificationCycle">
          <el-input-number v-model="form.verificationCycle" @change="handleChange" :min="1"
                           :max="10000" label="检定周期"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="检定日期" prop="lastVerification">
          <el-date-picker clearable size="small"
                          v-model="form.lastVerification"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择末次检定日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="有效期" prop="nextVerification">
          <el-input v-model="form.nextverification" placeholder="请输入有效期"/>
        </el-form-item>
        <el-form-item label="溯源方式" prop="traceableMode">
          <el-input v-model="form.traceableMode" placeholder="请输入溯源方式"/>
        </el-form-item>
        <el-form-item label="溯源单位" prop="traceableUnit">
          <el-input v-model="form.traceableUnit" placeholder="请输入溯源单位"/>
        </el-form-item>
        <el-form-item label="证书编号" prop="certificateNumber">
          <el-input v-model="form.certificateNumber" placeholder="请输入证书编号"/>
        </el-form-item>
        <br/>
        <el-form-item label="证书图片">
          <imageUpload v-model="form.area"/>
        </el-form-item>
        <br/>
        <el-form-item label="确认结论" prop="conclusion">
          <el-input v-model="form.conclusion" placeholder="请输入确认结论"/>
        </el-form-item>
        <el-form-item label="确认时间" prop="effect">
          <el-input v-model="form.effect" placeholder="请输入确认时间"/>
        </el-form-item>
        <el-form-item label="确认人" prop="powersupplymode">
          <el-input v-model="form.powersupplymode" placeholder="请输入确认人"/>
        </el-form-item>
        <el-form-item label="状态" prop="confirmationState">
          <el-input v-model="form.confirmationState" placeholder="请输入状态"/>
        </el-form-item>
        <el-form-item label="说明书">
          <imageUpload v-model="form.specification"/>
        </el-form-item>
        <br/>
        <el-form-item label="执行标准" prop="instrumentlv">
          <el-input v-model="form.instrumentlv" placeholder="请输入执行标准"/>
        </el-form-item>
        <el-form-item label="加入人员" prop="creator">
          <el-input v-model="form.creator" placeholder="请输入加入人员"/>
        </el-form-item>
        <el-form-item label="加入时间" prop="creationtime">
          <el-date-picker clearable size="small"
                          v-model="form.creationtime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择加入时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="完善人员" prop="perfect">
          <el-input v-model="form.perfect" placeholder="请输入完善人员"/>
        </el-form-item>
        <el-form-item label="完善时间" prop="perfecttime">
          <el-date-picker clearable size="small"
                          v-model="form.perfecttime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择完善时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="删除人员" prop="deleteor">
          <el-input v-model="form.deleteor" placeholder="请输入删除人员"/>
        </el-form-item>
        <el-form-item label="删除时间" prop="deletetime">
          <el-date-picker clearable size="small"
                          v-model="form.deletetime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择删除时间"
          >
          </el-date-picker>
        </el-form-item>


        <!--<el-form-item label="确认时间" prop="effect">-->
        <!--<el-input v-model="form.effect" placeholder="请输入确认时间"/>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="管径/供电方式" prop="powersupplymode">-->
        <!--<el-input v-model="form.powersupplymode" placeholder="请输入管径/供电方式"/>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="管理类别" prop="managementClass">-->

        <!--<el-select-->
        <!--v-model="form.managementClass"-->
        <!--placeholder="管理类别"-->
        <!--clearable-->
        <!--size="small"-->
        <!--style="width: 240px"-->
        <!--&gt;-->
        <!--<el-option-->
        <!--v-for="dict in dict.type.management_class"-->
        <!--:key="dict.value"-->
        <!--:label="dict.label"-->
        <!--:value="dict.value"-->
        <!--/>-->
        <!--</el-select>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="数据采集" prop="dataAcquisition">-->
        <!--<el-input v-model="form.dataAcquisition" placeholder="请输入数据采集"/>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="采集方式" prop="acquisitionmode">-->
        <!--<el-input v-model="form.acquisitionmode" placeholder="请输入采集方式"/>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="次检定日期" prop="nextVerification">-->
        <!--<el-input v-model="form.nextVerification" placeholder="请输入次检定日期"/>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="证书结论" prop="certificateConclusion">-->
        <!--<el-input v-model="form.certificateConclusion" placeholder="请输入证书结论"/>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="测量过程编号" prop="processNumber">-->
        <!--<el-input v-model="form.processNumber" placeholder="请输入测量过程编号"/>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="校准计量" prop="calibrationRecord">-->
        <!--<el-input v-model="form.calibrationRecord" placeholder="请输入校准计量"/>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="备注" prop="remark">-->
        <!--<el-input v-model="form.remark" placeholder="请输入备注"/>-->
        <!--</el-form-item>-->

        <!--        <el-form-item label="预留字段" prop="free2">-->
        <!--          <el-input v-model="form.free2" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free3">-->
        <!--          <el-input v-model="form.free3" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free4">-->
        <!--          <el-input v-model="form.free4" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free5">-->
        <!--          <el-input v-model="form.free5" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free6">-->
        <!--          <el-input v-model="form.free6" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free7">-->
        <!--          <el-input v-model="form.free7" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free8">-->
        <!--          <el-input v-model="form.free8" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free9">-->
        <!--          <el-input v-model="form.free9" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free11">-->
        <!--          <el-input v-model="form.free11" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free12">-->
        <!--          <el-input v-model="form.free12" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free13">-->
        <!--          <el-input v-model="form.free13" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free14">-->
        <!--          <el-input v-model="form.free14" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free15">-->
        <!--          <el-input v-model="form.free15" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free16">-->
        <!--          <el-input v-model="form.free16" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free17">-->
        <!--          <el-input v-model="form.free17" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free18">-->
        <!--          <el-input v-model="form.free18" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free19">-->
        <!--          <el-input v-model="form.free19" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free20">-->
        <!--          <el-input v-model="form.free20" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free21">-->
        <!--          <el-input v-model="form.free21" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free22">-->
        <!--          <el-input v-model="form.free22" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free23">-->
        <!--          <el-input v-model="form.free23" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free24">-->
        <!--          <el-input v-model="form.free24" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free25">-->
        <!--          <el-input v-model="form.free25" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free26">-->
        <!--          <el-input v-model="form.free26" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free27">-->
        <!--          <el-input v-model="form.free27" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free28">-->
        <!--          <el-input v-model="form.free28" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free29">-->
        <!--          <el-input v-model="form.free29" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="预留字段" prop="free30">-->
        <!--          <el-input v-model="form.free30" placeholder="请输入预留字段"/>-->
        <!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport"/>
            是否更新已经存在的用户数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false"
                   style="font-size:12px;vertical-align: baseline;"
                   @click="importTemplate"
          >下载模板
          </el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
  import {listLedger,listLedgerCount, getLedger, delLedger, addLedger, updateLedger} from '@/api/meter/ledger'
  import {getToken} from '@/utils/auth'

  export default {
    name: 'Ledger',
    dicts: ['management_class','managementclass'],

    data() {
      return {
        // 用户导入参数
        upload: {
          // 是否显示弹出层（用户导入）
          open: false,
          // 弹出层标题（用户导入）
          title: '',
          // 是否禁用上传
          isUploading: false,
          // 是否更新已经存在的用户数据
          updateSupport: 0,
          // 设置上传的请求头部
          headers: {Authorization: 'Bearer ' + getToken()},
          // 上传的地址
          url: process.env.VUE_APP_BASE_API + '/meter/ledger/importData'
        },
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 计量台账表格数据
        ledgerList: [],
        // 弹出层标题
        title: '',
        // 是否打开图片弹出层
        pictureOpen: false,
        // 是否显示弹出层
        open: false,
        // 有效期时间范围
        daterangeNextVerification: [],

        queryCount: {
          free20: 0,
          free21: 0,
          free22: 0,
        },
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          free1:null,
          managementUnit: null,
          designation: null,
          deviceType: null,
          verificationCycle: null,
          lastVerification: null,
          expirationDate: null,
          nextVerification: null,
          traceableUnit: null,
          traceableMode: null,
          certificateNumber: null,
          certificateConclusion: null,
          conclusion: null,
          confirmationState: null,
          processNumber: null,
          calibrationRecord: null,
          specification: null,
          creator: null,
          creationtime: null,
          perfect: null,
          perfecttime: null,
          deleteor: null,
          deletetime: null

        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {}
      }
    },
    created() {

      var company = this.$route.query.id
      this.queryParams.managementUnit = company
      this.getList()
    },
    methods: {

      handleChange(value) {
        console.log(value)
      },
      /** 查询计量台账列表 */
      getList() {
        this.loading = true
        this.queryParams.params = {};
        if (null != this.daterangeNextVerification && '' != this.daterangeNextVerification) {
          this.queryParams.params["beginNextVerification"] = this.daterangeNextVerification[0];
          this.queryParams.params["endNextVerification"] = this.daterangeNextVerification[1];
        }
        listLedger(this.queryParams).then(response => {
          this.ledgerList = response.rows
          this.total = response.total
          this.loading = false
        })
        listLedgerCount(this.queryParams).then(response => {
          this.queryCount=response.data;
          console.log(this.queryCount)
          // response.data.free20
          // response.data.free21
          // response.data.free22
        })

      },
      // 取消按钮
      cancel() {
        this.open = false
        this.reset()
      },
      // 表单重置
      reset() {
        this.form = {
          projectId: null,
          managementUnit: null,
          area: null,
          process: null,
          position: null,
          storageMedium: null,
          designation: null,
          deviceType: null,
          effect: null,
          brand: null,
          modelNumber: null,
          powersupplymode: null,
          measurementRange: null,
          errorMargin: null,
          instrumentlv: null,
          managementClass: null,
          stats: null,
          dataAcquisition: null,
          acquisitionmode: null,
          verificationCycle: 1,
          lastVerification: null,
          expirationDate: null,
          nextVerification: null,
          traceableUnit: null,
          traceableMode: null,
          certificateNumber: null,
          certificateConclusion: null,
          conclusion: null,
          confirmationState: null,
          processNumber: null,
          calibrationRecord: null,
          specification: null,
          creator: null,
          creationtime: null,
          perfect: null,
          perfecttime: null,
          deleteor: null,
          deletetime: null,
          remark: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          free1: null,
          free2: null,
          free3: null,
          free4: null,
          free5: null,
          free6: null,
          free7: null,
          free8: null,
          free9: null,
          free11: null,
          free12: null,
          free13: null,
          free14: null,
          free15: null,
          free16: null,
          free17: null,
          free18: null,
          free19: null,
          free20: null,
          free21: null,
          free22: null,
          free23: null,
          free24: null,
          free25: null,
          free26: null,
          free27: null,
          free28: null,
          free29: null,
          free30: null
        }
        this.resetForm('form')
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1
        this.getList()
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.daterangeNextVerification = [];
        this.resetForm('queryForm')
        this.handleQuery()
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.projectId)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 图片按钮操作 */
      handlePicture(row) {
        this.reset()
        const projectId = row.projectId || this.ids
        console.log(projectId,'666')
        getLedger(projectId).then(response => {
          this.form = response.data
          this.pictureOpen = true
          this.title = '修改图片'
        })

      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset()
        this.open = true
        this.title = '添加计量台账'
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset()
        const projectId = row.projectId || this.ids
        console.log(projectId)
        getLedger(projectId).then(response => {
          this.form = response.data
          this.open = true
          this.title = '修改计量台账'
        })
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs['form'].validate(valid => {
          if (valid) {
            if (this.form.projectId != null) {
              updateLedger(this.form).then(response => {
                this.$modal.msgSuccess('修改成功')
                this.open = false
                this.getList()
              })
            } else {
              addLedger(this.form).then(response => {
                this.$modal.msgSuccess('新增成功')
                this.open = false
                this.getList()
              })
            }
          }
        })
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const projectIds = row.projectId || this.ids
        this.$modal.confirm('是否确认删除计量台账编号为"' + projectIds + '"的数据项？').then(function () {
          return delLedger(projectIds)
        }).then(() => {
          this.getList()
          this.$modal.msgSuccess('删除成功')
        }).catch(() => {
        })
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('meter/ledger/export', {
          ...this.queryParams
        }, `ledger_${new Date().getTime()}.xlsx`)
      },
      /** 导出按钮操作 */
      handleExportPlan() {
        this.download('meter/ledger/exportplan', {
          ...this.queryParams
        }, `ledger_${new Date().getTime()}.xlsx`)
      },
      /** 导入按钮操作 */
      handleImport() {
        this.upload.title = '用户导入'
        this.upload.open = true
      },
      /** 下载模板操作 */
      importTemplate() {
        this.download('meter/ledger/importTemplate', {}, `user_template_${new Date().getTime()}.xlsx`)
      },
      // 文件上传中处理
      handleFileUploadProgress(event, file, fileList) {
        this.upload.isUploading = true
      },
      // 文件上传成功处理
      handleFileSuccess(response, file, fileList) {
        this.upload.open = false
        this.upload.isUploading = false
        this.$refs.upload.clearFiles()
        this.$alert('<div style=\'overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;\'>' + response.msg + '</div>', '导入结果', {dangerouslyUseHTMLString: true})
        this.getList()
      },
      // 提交上传文件
      submitFileForm() {
        this.$refs.upload.submit()
      }

    }
  }
</script>
